package my.mybatis.common.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateSyncUtil {
	private static SimpleDateFormat sdf_YYYY_MM_DD_HH_MM_SS = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    private static SimpleDateFormat sdf_YYYY_MM_DD_HH_MM = new SimpleDateFormat("yyyy-MM-dd HH:mm");
    private static SimpleDateFormat sdf_YYYY_MM_DD = new SimpleDateFormat("yyyy-MM-dd");
    public static String formatDate(Date date)throws ParseException{
        synchronized(sdf_YYYY_MM_DD_HH_MM_SS){
            return sdf_YYYY_MM_DD_HH_MM_SS.format(date);
        }  
    }
    
    public static Date parse(String strDate) throws ParseException{
        synchronized(sdf_YYYY_MM_DD_HH_MM_SS){
            return sdf_YYYY_MM_DD_HH_MM_SS.parse(strDate);
        }
    }

    public static String formatDate_ymdhm(Date date)throws ParseException{
        synchronized(sdf_YYYY_MM_DD_HH_MM){
            return sdf_YYYY_MM_DD_HH_MM.format(date);
        }
    }

    public static Date parse_ymdhm(String strDate) throws ParseException{
        synchronized(sdf_YYYY_MM_DD_HH_MM){
            return sdf_YYYY_MM_DD_HH_MM.parse(strDate);
        }
    }

    public static String formatDate_ymd(Date date)throws ParseException{
        synchronized(sdf_YYYY_MM_DD){
            return sdf_YYYY_MM_DD.format(date);
        }
    }

    public static Date parse_ymd(String strDate) throws ParseException{
        synchronized(sdf_YYYY_MM_DD){
            return sdf_YYYY_MM_DD.parse(strDate);
        }
    }
}
